using Cinemachine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class cameraDown : MonoBehaviour
{

    public CinemachineVirtualCamera VirtualCamera;
    Vector2 startPosition;
    float downDistance = 3;
    float startZ;
    // Start is called before the first frame update
    void Start()
    {
        startPosition = VirtualCamera.transform.position;
        startZ = VirtualCamera.transform.position.z;
    }

    // Update is called once per frame
    void Update()
    {
        CameraDownWithRole();
        CameraUp();
    }

    public void CameraDownWithRole()
    {
        if(Input.GetKeyDown(KeyCode.S)&&VirtualCamera.enabled==true) 
        {
            float newY = startPosition.y-downDistance;
            VirtualCamera.transform.position = new Vector3(startPosition.x, newY, startZ);
        }
    }

    public void CameraUp()
    {
        if( Input.GetKeyUp(KeyCode.S)&&VirtualCamera.enabled == true)
        {
            VirtualCamera.transform.position = new Vector3(startPosition.x, startPosition.y, startZ);
        }
    }
}
